
/****** Object:  StoredProcedure [proc_Tataya_CategoryLoadByPrimaryKey]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_CategoryLoadByPrimaryKey]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_CategoryLoadByPrimaryKey];
GO

CREATE PROCEDURE [proc_Tataya_CategoryLoadByPrimaryKey]
(
	@ID int
)
AS
BEGIN
	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[CategoryName],
		[Description],
		[CreatedDate],
		[CreatedByUserID],
		[ModifiedDate],
		[ModifiedByUserID]
	FROM [Tataya_Category]
	WHERE
		([ID] = @ID)

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_CategoryLoadByPrimaryKey Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_CategoryLoadByPrimaryKey Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_CategoryLoadAll]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_CategoryLoadAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_CategoryLoadAll];
GO

CREATE PROCEDURE [proc_Tataya_CategoryLoadAll]
AS
BEGIN

	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[CategoryName],
		[Description],
		[CreatedDate],
		[CreatedByUserID],
		[ModifiedDate],
		[ModifiedByUserID]
	FROM [Tataya_Category]

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_CategoryLoadAll Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_CategoryLoadAll Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_CategoryUpdate]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_CategoryUpdate]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_CategoryUpdate];
GO

CREATE PROCEDURE [proc_Tataya_CategoryUpdate]
(
	@ID int,
	@CategoryName nvarchar(100),
	@Description nvarchar(1000) = NULL,
	@CreatedDate datetime,
	@CreatedByUserID int,
	@ModifiedDate datetime = NULL,
	@ModifiedByUserID int = NULL
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	UPDATE [Tataya_Category]
	SET
		[CategoryName] = @CategoryName,
		[Description] = @Description,
		[CreatedDate] = @CreatedDate,
		[CreatedByUserID] = @CreatedByUserID,
		[ModifiedDate] = @ModifiedDate,
		[ModifiedByUserID] = @ModifiedByUserID
	WHERE
		[ID] = @ID


	SET @Err = @@Error


	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_CategoryUpdate Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_CategoryUpdate Error on Creation'
GO




/****** Object:  StoredProcedure [proc_Tataya_CategoryInsert]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_CategoryInsert]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_CategoryInsert];
GO

CREATE PROCEDURE [proc_Tataya_CategoryInsert]
(
	@ID int = NULL output,
	@CategoryName nvarchar(100),
	@Description nvarchar(1000) = NULL,
	@CreatedDate datetime,
	@CreatedByUserID int,
	@ModifiedDate datetime = NULL,
	@ModifiedByUserID int = NULL
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	INSERT
	INTO [Tataya_Category]
	(
		[CategoryName],
		[Description],
		[CreatedDate],
		[CreatedByUserID],
		[ModifiedDate],
		[ModifiedByUserID]
	)
	VALUES
	(
		@CategoryName,
		@Description,
		@CreatedDate,
		@CreatedByUserID,
		@ModifiedDate,
		@ModifiedByUserID
	)

	SET @Err = @@Error

	SELECT @ID = SCOPE_IDENTITY()

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_CategoryInsert Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_CategoryInsert Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_CategoryDelete]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_CategoryDelete]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_CategoryDelete];
GO

CREATE PROCEDURE [proc_Tataya_CategoryDelete]
(
	@ID int
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	DELETE
	FROM [Tataya_Category]
	WHERE
		[ID] = @ID
	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_CategoryDelete Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_CategoryDelete Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_CustomerLoadByPrimaryKey]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_CustomerLoadByPrimaryKey]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_CustomerLoadByPrimaryKey];
GO

CREATE PROCEDURE [proc_Tataya_CustomerLoadByPrimaryKey]
(
	@ID int
)
AS
BEGIN
	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[FullName],
		[Phone],
		[Address],
		[CreatedDate]
	FROM [Tataya_Customer]
	WHERE
		([ID] = @ID)

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_CustomerLoadByPrimaryKey Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_CustomerLoadByPrimaryKey Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_CustomerLoadAll]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_CustomerLoadAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_CustomerLoadAll];
GO

CREATE PROCEDURE [proc_Tataya_CustomerLoadAll]
AS
BEGIN

	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[FullName],
		[Phone],
		[Address],
		[CreatedDate]
	FROM [Tataya_Customer]

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_CustomerLoadAll Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_CustomerLoadAll Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_CustomerUpdate]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_CustomerUpdate]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_CustomerUpdate];
GO

CREATE PROCEDURE [proc_Tataya_CustomerUpdate]
(
	@ID int,
	@FullName nvarchar(200),
	@Phone varchar(50),
	@Address nvarchar(1000),
	@CreatedDate datetime
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	UPDATE [Tataya_Customer]
	SET
		[FullName] = @FullName,
		[Phone] = @Phone,
		[Address] = @Address,
		[CreatedDate] = @CreatedDate
	WHERE
		[ID] = @ID


	SET @Err = @@Error


	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_CustomerUpdate Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_CustomerUpdate Error on Creation'
GO




/****** Object:  StoredProcedure [proc_Tataya_CustomerInsert]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_CustomerInsert]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_CustomerInsert];
GO

CREATE PROCEDURE [proc_Tataya_CustomerInsert]
(
	@ID int = NULL output,
	@FullName nvarchar(200),
	@Phone varchar(50),
	@Address nvarchar(1000),
	@CreatedDate datetime
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	INSERT
	INTO [Tataya_Customer]
	(
		[FullName],
		[Phone],
		[Address],
		[CreatedDate]
	)
	VALUES
	(
		@FullName,
		@Phone,
		@Address,
		@CreatedDate
	)

	SET @Err = @@Error

	SELECT @ID = SCOPE_IDENTITY()

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_CustomerInsert Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_CustomerInsert Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_CustomerDelete]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_CustomerDelete]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_CustomerDelete];
GO

CREATE PROCEDURE [proc_Tataya_CustomerDelete]
(
	@ID int
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	DELETE
	FROM [Tataya_Customer]
	WHERE
		[ID] = @ID
	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_CustomerDelete Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_CustomerDelete Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_ImageLoadByPrimaryKey]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_ImageLoadByPrimaryKey]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_ImageLoadByPrimaryKey];
GO

CREATE PROCEDURE [proc_Tataya_ImageLoadByPrimaryKey]
(
	@ID int
)
AS
BEGIN
	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[ImageFile],
		[Title],
		[ProductID],
		[Category],
		[CreatedDate],
		[CreatedByUserID],
		[ModifiedDate],
		[ModifiedByUserID]
	FROM [Tataya_Image]
	WHERE
		([ID] = @ID)

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_ImageLoadByPrimaryKey Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_ImageLoadByPrimaryKey Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_ImageLoadAll]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_ImageLoadAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_ImageLoadAll];
GO

CREATE PROCEDURE [proc_Tataya_ImageLoadAll]
AS
BEGIN

	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[ImageFile],
		[Title],
		[ProductID],
		[Category],
		[CreatedDate],
		[CreatedByUserID],
		[ModifiedDate],
		[ModifiedByUserID]
	FROM [Tataya_Image]

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_ImageLoadAll Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_ImageLoadAll Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_ImageUpdate]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_ImageUpdate]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_ImageUpdate];
GO

CREATE PROCEDURE [proc_Tataya_ImageUpdate]
(
	@ID int,
	@ImageFile nvarchar(100),
	@Title nvarchar(300),
	@ProductID int,
	@Category varchar(100),
	@CreatedDate datetime,
	@CreatedByUserID int,
	@ModifiedDate datetime = NULL,
	@ModifiedByUserID int = NULL
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	UPDATE [Tataya_Image]
	SET
		[ImageFile] = @ImageFile,
		[Title] = @Title,
		[ProductID] = @ProductID,
		[Category] = @Category,
		[CreatedDate] = @CreatedDate,
		[CreatedByUserID] = @CreatedByUserID,
		[ModifiedDate] = @ModifiedDate,
		[ModifiedByUserID] = @ModifiedByUserID
	WHERE
		[ID] = @ID


	SET @Err = @@Error


	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_ImageUpdate Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_ImageUpdate Error on Creation'
GO




/****** Object:  StoredProcedure [proc_Tataya_ImageInsert]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_ImageInsert]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_ImageInsert];
GO

CREATE PROCEDURE [proc_Tataya_ImageInsert]
(
	@ID int = NULL output,
	@ImageFile nvarchar(100),
	@Title nvarchar(300),
	@ProductID int,
	@Category varchar(100),
	@CreatedDate datetime,
	@CreatedByUserID int,
	@ModifiedDate datetime = NULL,
	@ModifiedByUserID int = NULL
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	INSERT
	INTO [Tataya_Image]
	(
		[ImageFile],
		[Title],
		[ProductID],
		[Category],
		[CreatedDate],
		[CreatedByUserID],
		[ModifiedDate],
		[ModifiedByUserID]
	)
	VALUES
	(
		@ImageFile,
		@Title,
		@ProductID,
		@Category,
		@CreatedDate,
		@CreatedByUserID,
		@ModifiedDate,
		@ModifiedByUserID
	)

	SET @Err = @@Error

	SELECT @ID = SCOPE_IDENTITY()

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_ImageInsert Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_ImageInsert Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_ImageDelete]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_ImageDelete]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_ImageDelete];
GO

CREATE PROCEDURE [proc_Tataya_ImageDelete]
(
	@ID int
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	DELETE
	FROM [Tataya_Image]
	WHERE
		[ID] = @ID
	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_ImageDelete Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_ImageDelete Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_OrderLoadByPrimaryKey]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_OrderLoadByPrimaryKey]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_OrderLoadByPrimaryKey];
GO

CREATE PROCEDURE [proc_Tataya_OrderLoadByPrimaryKey]
(
	@ID int
)
AS
BEGIN
	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[OrderCode],
		[CustomerID],
		[CreatedDate]
	FROM [Tataya_Order]
	WHERE
		([ID] = @ID)

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_OrderLoadByPrimaryKey Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_OrderLoadByPrimaryKey Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_OrderLoadAll]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_OrderLoadAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_OrderLoadAll];
GO

CREATE PROCEDURE [proc_Tataya_OrderLoadAll]
AS
BEGIN

	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[OrderCode],
		[CustomerID],
		[CreatedDate]
	FROM [Tataya_Order]

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_OrderLoadAll Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_OrderLoadAll Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_OrderUpdate]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_OrderUpdate]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_OrderUpdate];
GO

CREATE PROCEDURE [proc_Tataya_OrderUpdate]
(
	@ID int,
	@OrderCode varchar(50),
	@CustomerID int,
	@CreatedDate datetime
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	UPDATE [Tataya_Order]
	SET
		[OrderCode] = @OrderCode,
		[CustomerID] = @CustomerID,
		[CreatedDate] = @CreatedDate
	WHERE
		[ID] = @ID


	SET @Err = @@Error


	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_OrderUpdate Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_OrderUpdate Error on Creation'
GO




/****** Object:  StoredProcedure [proc_Tataya_OrderInsert]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_OrderInsert]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_OrderInsert];
GO

CREATE PROCEDURE [proc_Tataya_OrderInsert]
(
	@ID int,
	@OrderCode varchar(50),
	@CustomerID int,
	@CreatedDate datetime
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	INSERT
	INTO [Tataya_Order]
	(
		[ID],
		[OrderCode],
		[CustomerID],
		[CreatedDate]
	)
	VALUES
	(
		@ID,
		@OrderCode,
		@CustomerID,
		@CreatedDate
	)

	SET @Err = @@Error


	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_OrderInsert Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_OrderInsert Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_OrderDelete]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_OrderDelete]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_OrderDelete];
GO

CREATE PROCEDURE [proc_Tataya_OrderDelete]
(
	@ID int
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	DELETE
	FROM [Tataya_Order]
	WHERE
		[ID] = @ID
	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_OrderDelete Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_OrderDelete Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_OrderDetailLoadByPrimaryKey]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_OrderDetailLoadByPrimaryKey]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_OrderDetailLoadByPrimaryKey];
GO

CREATE PROCEDURE [proc_Tataya_OrderDetailLoadByPrimaryKey]
(
	@ID int
)
AS
BEGIN
	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[ProductID],
		[Number],
		[OrderPrice],
		[OrderStatus],
		[OrderID],
		[CreatedDate]
	FROM [Tataya_OrderDetail]
	WHERE
		([ID] = @ID)

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_OrderDetailLoadByPrimaryKey Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_OrderDetailLoadByPrimaryKey Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_OrderDetailLoadAll]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_OrderDetailLoadAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_OrderDetailLoadAll];
GO

CREATE PROCEDURE [proc_Tataya_OrderDetailLoadAll]
AS
BEGIN

	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[ProductID],
		[Number],
		[OrderPrice],
		[OrderStatus],
		[OrderID],
		[CreatedDate]
	FROM [Tataya_OrderDetail]

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_OrderDetailLoadAll Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_OrderDetailLoadAll Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_OrderDetailUpdate]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_OrderDetailUpdate]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_OrderDetailUpdate];
GO

CREATE PROCEDURE [proc_Tataya_OrderDetailUpdate]
(
	@ID int,
	@ProductID int,
	@Number int,
	@OrderPrice money,
	@OrderStatus int,
	@OrderID int,
	@CreatedDate datetime
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	UPDATE [Tataya_OrderDetail]
	SET
		[ProductID] = @ProductID,
		[Number] = @Number,
		[OrderPrice] = @OrderPrice,
		[OrderStatus] = @OrderStatus,
		[OrderID] = @OrderID,
		[CreatedDate] = @CreatedDate
	WHERE
		[ID] = @ID


	SET @Err = @@Error


	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_OrderDetailUpdate Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_OrderDetailUpdate Error on Creation'
GO




/****** Object:  StoredProcedure [proc_Tataya_OrderDetailInsert]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_OrderDetailInsert]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_OrderDetailInsert];
GO

CREATE PROCEDURE [proc_Tataya_OrderDetailInsert]
(
	@ID int = NULL output,
	@ProductID int,
	@Number int,
	@OrderPrice money,
	@OrderStatus int,
	@OrderID int,
	@CreatedDate datetime
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	INSERT
	INTO [Tataya_OrderDetail]
	(
		[ProductID],
		[Number],
		[OrderPrice],
		[OrderStatus],
		[OrderID],
		[CreatedDate]
	)
	VALUES
	(
		@ProductID,
		@Number,
		@OrderPrice,
		@OrderStatus,
		@OrderID,
		@CreatedDate
	)

	SET @Err = @@Error

	SELECT @ID = SCOPE_IDENTITY()

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_OrderDetailInsert Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_OrderDetailInsert Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_OrderDetailDelete]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_OrderDetailDelete]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_OrderDetailDelete];
GO

CREATE PROCEDURE [proc_Tataya_OrderDetailDelete]
(
	@ID int
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	DELETE
	FROM [Tataya_OrderDetail]
	WHERE
		[ID] = @ID
	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_OrderDetailDelete Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_OrderDetailDelete Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_ProductLoadByPrimaryKey]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_ProductLoadByPrimaryKey]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_ProductLoadByPrimaryKey];
GO

CREATE PROCEDURE [proc_Tataya_ProductLoadByPrimaryKey]
(
	@ID int
)
AS
BEGIN
	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[ProductName],
		[ProductCode],
		[Price],
		[ProductDetail],
		[ImageFile],
		[CategoryID],
		[CreatedDate],
		[CreatedByUserID],
		[ModifiedDate],
		[ModifiedByUserID]
	FROM [Tataya_Product]
	WHERE
		([ID] = @ID)

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_ProductLoadByPrimaryKey Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_ProductLoadByPrimaryKey Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_ProductLoadAll]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_ProductLoadAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_ProductLoadAll];
GO

CREATE PROCEDURE [proc_Tataya_ProductLoadAll]
AS
BEGIN

	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[ProductName],
		[ProductCode],
		[Price],
		[ProductDetail],
		[ImageFile],
		[CategoryID],
		[CreatedDate],
		[CreatedByUserID],
		[ModifiedDate],
		[ModifiedByUserID]
	FROM [Tataya_Product]

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_ProductLoadAll Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_ProductLoadAll Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_ProductUpdate]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_ProductUpdate]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_ProductUpdate];
GO

CREATE PROCEDURE [proc_Tataya_ProductUpdate]
(
	@ID int,
	@ProductName nvarchar(100),
	@ProductCode varchar(50),
	@Price money = NULL,
	@ProductDetail nvarchar(MAX) = NULL,
	@ImageFile nvarchar(100) = NULL,
	@CategoryID int,
	@CreatedDate datetime,
	@CreatedByUserID int,
	@ModifiedDate datetime = NULL,
	@ModifiedByUserID int = NULL
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	UPDATE [Tataya_Product]
	SET
		[ProductName] = @ProductName,
		[ProductCode] = @ProductCode,
		[Price] = @Price,
		[ProductDetail] = @ProductDetail,
		[ImageFile] = @ImageFile,
		[CategoryID] = @CategoryID,
		[CreatedDate] = @CreatedDate,
		[CreatedByUserID] = @CreatedByUserID,
		[ModifiedDate] = @ModifiedDate,
		[ModifiedByUserID] = @ModifiedByUserID
	WHERE
		[ID] = @ID


	SET @Err = @@Error


	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_ProductUpdate Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_ProductUpdate Error on Creation'
GO




/****** Object:  StoredProcedure [proc_Tataya_ProductInsert]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_ProductInsert]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_ProductInsert];
GO

CREATE PROCEDURE [proc_Tataya_ProductInsert]
(
	@ID int = NULL output,
	@ProductName nvarchar(100),
	@ProductCode varchar(50),
	@Price money = NULL,
	@ProductDetail nvarchar(MAX) = NULL,
	@ImageFile nvarchar(100) = NULL,
	@CategoryID int,
	@CreatedDate datetime,
	@CreatedByUserID int,
	@ModifiedDate datetime = NULL,
	@ModifiedByUserID int = NULL
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	INSERT
	INTO [Tataya_Product]
	(
		[ProductName],
		[ProductCode],
		[Price],
		[ProductDetail],
		[ImageFile],
		[CategoryID],
		[CreatedDate],
		[CreatedByUserID],
		[ModifiedDate],
		[ModifiedByUserID]
	)
	VALUES
	(
		@ProductName,
		@ProductCode,
		@Price,
		@ProductDetail,
		@ImageFile,
		@CategoryID,
		@CreatedDate,
		@CreatedByUserID,
		@ModifiedDate,
		@ModifiedByUserID
	)

	SET @Err = @@Error

	SELECT @ID = SCOPE_IDENTITY()

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_ProductInsert Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_ProductInsert Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_ProductDelete]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_ProductDelete]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_ProductDelete];
GO

CREATE PROCEDURE [proc_Tataya_ProductDelete]
(
	@ID int
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	DELETE
	FROM [Tataya_Product]
	WHERE
		[ID] = @ID
	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_ProductDelete Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_ProductDelete Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_UserLoadByPrimaryKey]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_UserLoadByPrimaryKey]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_UserLoadByPrimaryKey];
GO

CREATE PROCEDURE [proc_Tataya_UserLoadByPrimaryKey]
(
	@ID int
)
AS
BEGIN
	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[Username],
		[Password],
		[FullName],
		[CreatedDate]
	FROM [Tataya_User]
	WHERE
		([ID] = @ID)

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_UserLoadByPrimaryKey Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_UserLoadByPrimaryKey Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_UserLoadAll]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_UserLoadAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_UserLoadAll];
GO

CREATE PROCEDURE [proc_Tataya_UserLoadAll]
AS
BEGIN

	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[Username],
		[Password],
		[FullName],
		[CreatedDate]
	FROM [Tataya_User]

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_UserLoadAll Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_UserLoadAll Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_UserUpdate]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_UserUpdate]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_UserUpdate];
GO

CREATE PROCEDURE [proc_Tataya_UserUpdate]
(
	@ID int,
	@Username varchar(20),
	@Password varchar(50),
	@FullName nvarchar(200),
	@CreatedDate datetime
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	UPDATE [Tataya_User]
	SET
		[Username] = @Username,
		[Password] = @Password,
		[FullName] = @FullName,
		[CreatedDate] = @CreatedDate
	WHERE
		[ID] = @ID


	SET @Err = @@Error


	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_UserUpdate Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_UserUpdate Error on Creation'
GO




/****** Object:  StoredProcedure [proc_Tataya_UserInsert]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_UserInsert]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_UserInsert];
GO

CREATE PROCEDURE [proc_Tataya_UserInsert]
(
	@ID int = NULL output,
	@Username varchar(20),
	@Password varchar(50),
	@FullName nvarchar(200),
	@CreatedDate datetime
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	INSERT
	INTO [Tataya_User]
	(
		[Username],
		[Password],
		[FullName],
		[CreatedDate]
	)
	VALUES
	(
		@Username,
		@Password,
		@FullName,
		@CreatedDate
	)

	SET @Err = @@Error

	SELECT @ID = SCOPE_IDENTITY()

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_UserInsert Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_UserInsert Error on Creation'
GO

/****** Object:  StoredProcedure [proc_Tataya_UserDelete]    Script Date: 7/29/2011 7:12:09 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_Tataya_UserDelete]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_Tataya_UserDelete];
GO

CREATE PROCEDURE [proc_Tataya_UserDelete]
(
	@ID int
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	DELETE
	FROM [Tataya_User]
	WHERE
		[ID] = @ID
	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_Tataya_UserDelete Succeeded'
ELSE PRINT 'Procedure Creation: proc_Tataya_UserDelete Error on Creation'
GO


